package com.zhijian.warehouse.manage.config;

import com.zhijian.util.EncryptUtil;
import com.zhijian.warehouse.manage.util.NetUtil;
import com.zhijian.warehouse.manage.util.SnowFlake;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import javax.servlet.http.HttpServletRequest;

public interface RequestTracker {
    public static final Logger log = LoggerFactory.getLogger(RequestTracker.class);
    long START_TIME = 1609434061000L;
    SnowFlake SEQ_KE = new SnowFlake(10L, 11L);
    String TRACK_NAME = "trackId";
    String SERVER_IP_NAME = "serverIp";
    String SERVER_IP = NetUtil.getLocalIp();
    
    default void createTrackId(HttpServletRequest request) {
        try {
            String requestUrl = EncryptUtil.md5(request.getServletPath() + "_" + System.currentTimeMillis());
        } catch (Exception var4) {
            Exception ex = var4;
        }
        MDC.put("serverIp", SERVER_IP);
    }
    
    
    default void clearTrackId() {
        MDC.put("serverIp", (String) null);
    }
    
    public static String getOrigin(HttpServletRequest request) {
        return request.getHeader("Origin");
    }
}
